﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NPMonitor.Interfaces;
using NPMonitor.Interfaces.Internal;
using NPMonitor.DataModel.Internal;

namespace NPMonitor.Implementation.Internal
{
	/// <summary>
	/// Manages the creation of <see cref="Interfaces.Internal.IJobExecutor"/> according to the type of job.
	/// </summary>
	internal class JobExecutorFactory : IJobExecutorFactory
	{
		/// <summary>
		/// Gets the job executor.
		/// </summary>
		/// <param name="jobContext">The job context.</param>
		/// <returns></returns>
		public IJobExecutor GetJobExecutor(JobContext jobContext)
		{
            if (jobContext.JobData.JobTaskType == TaskType.Workflow)
                return new WorkflowJobExecutor();
            else
                return new DefaultJobExecutor();

            // Some jobInstance will be created when execute, edited by ray - 2012/12/4
            //if (jobContext.JobInstance is IJob)
            //{
            //    return new DefaultJobExecutor();
            //}
            //throw new ArgumentException("jobContext.JobInstance");
		}
	}
}
